package net.shopxx.entity;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.ManyToMany;
import javax.persistence.Transient;

import org.hibernate.annotations.ForeignKey;

@Entity
// @JsonIgnoreProperties({"hibernateLazyInitializer", "handler", "createDate",
// "modifyDate", "specificationValueStore", "goodsSet", "json"})
public class Specification extends BaseEntity {
	private static final long serialVersionUID = -6346775052811140926L;
	private String name;
	private int specificationType;
	private String memo;
	private String specificationValueStore;// SpecificationValueStore
	private Integer orderList;// 排序
	private Set<Goods> goodsSet;

	@Column(nullable = false)
	public String getName() {
		return this.name;
	}

	public void setName(String paramString) {
		this.name = paramString;
	}

	@Column(nullable = false)
	public int getSpecificationType() {
		return this.specificationType;
	}

	public void setSpecificationType(int specificationType) {
		this.specificationType = specificationType;
	}

	@Column(nullable = false)
	/**
	 * @return the memo
	 */
	public String getMemo() {
		return memo;
	}

	/**
	 * @param memo
	 *            the memo to set
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}

	@Column(nullable = false, length = 3000)
	/**
	 * @return the specificationValueStore
	 */
	public String getSpecificationValueStore() {
		return specificationValueStore;
	}

	/**
	 * @param specificationValueStore
	 *            the specificationValueStore to set
	 */
	public void setSpecificationValueStore(String specificationValueStore) {
		this.specificationValueStore = specificationValueStore;
	}

	/**
	 * @return the orderList
	 */
	public Integer getOrderList() {
		return orderList;
	}

	/**
	 * @param orderList
	 *            the orderList to set
	 */
	public void setOrderList(Integer orderList) {
		this.orderList = orderList;
	}

	@ManyToMany(mappedBy = "specificationSet", fetch = FetchType.EAGER)
	// @ForeignKey(name="fk_specification_product_set")
	/**
	 * @return the goodsSet
	 */
	public Set<Goods> getGoodsSet() {
		return goodsSet;
	}

	/**
	 * @param goodsSet
	 *            the goodsSet to set
	 */
	public void setGoodsSet(Set<Goods> goodsSet) {
		this.goodsSet = goodsSet;
	}

	// @Transient
	// public List<IIIlIlIl> getSpecificationValueList()
	// {
	// if (StringUtils.isEmpty(this.lllIlIIII))
	// return null;
	// try
	// {
	// return (List)IIIIIlII.IIIIIIII(this.lllIlIIII, new IIIlIllI(this));
	// }
	// catch (Exception localException)
	// {
	// }
	// return null;
	// }

	// @Transient
	// public void setSpecificationValueList(List<IIIlIlIl> paramList)
	// {
	// if ((paramList == null) || (paramList.size() == 0))
	// return;
	// Collections.sort(paramList);
	// this.lllIlIIII = IIIIIlII.IIIIIIIl(paramList);
	// }

	@Transient
	public void onSave() {
		if ((this.orderList == null) || (this.orderList.intValue() < 0))
			this.orderList = Integer.valueOf(0);
	}

	@Transient
	public void onUpdate() {
		if ((this.orderList == null) || (this.orderList.intValue() < 0))
			this.orderList = Integer.valueOf(0);
	}

	// @Transient
	// public String getJson()
	// {
	// return IIIIIlII.IIIIIIIl(this);
	// }
}
